package com.ruoyi.web.controller.aj;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.aj.domain.Client;
import com.ruoyi.aj.service.ClientService;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/client")
@DataSource(DataSourceType.SLAVE)
public class ClientController {

    @Autowired
    private ClientService clientService;


    @GetMapping("/clientsave")
    public Object clientlist(Client client){
        String addtime=new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        client.setAddtime(addtime);
        clientService.save(client);
        QueryWrapper<Client> wrapper=new QueryWrapper<>();
        if (client.getClient()!=null){
            wrapper.eq("client",client.getClient());
        }
        return clientService.list(wrapper);
    }


}
